Twenty minutes of screensaver in 60 seconds

June 12, 2020, 12:44 pm

For those people who aren't running a recent version of MacOS and weren't able to install my Patrick O'Brian screensaver, this is a video I recorded of it (sped up to fit in 60 seconds):

Permalink - Comments - Tags: Development,Patrick O'Brian

Patrick O'Brian Mapping Project Screensaver

May 17, 2020, 6:55 am

I have completed a 1.0 version of my Patrick O'Brian screensaver. This software should work (no guarantees) on MacOS 10.12 (Sierra) or later. To install, unzip and then double click Voyages.saver. You will be asked to install the screensaver for "this user" or "all users". Please see the terms of use below (N.B. Satellite imagery is provided by and copyright © MapTiler © OpenStreetMap contributors).

If you aren't interested in the implementation details and would like a copy, you can skip the rest of the post and download the screensaver here:

Download

N.B. I am pretty sure I jumped through all the hoops I need to so that this screensaver can be installed without dire warnings, but please let me know if you aren't able to install it.

I wanted a full screen satellite map with the characters journeys (based on my latitude/longitude data) rendered on top. There are native libraries out there to do that kind of thing, but I thought it would be interesting to try and do some of this myself.

I started out hunting around for the Web Mercator Projection algorithm that GoogleMaps uses. There is a pretty good explanation of this in the Google Maps Javascript API docs. I do wonder though how that Javascript code translates to the projection formulas for x and y. I am missing something there.

Someone had kindly ported that code to Swift so I was able to use that to get latitudes and longitudes successfully projected onto the screen:

Next step was to get hold of a satellite imagery tileset (obviously based on the Mercator Projection) that was free and easy to embed in my native app (no dependancy on an Internet connection for me). Fortunately OpenMapTiles had exactly what I needed. I didn't really need the full 186Gb dataset (although if I had a spare pile of cash lying around it would be fun to play with) so I grabbed the low res tileset.

The download is basically just a SQLLite database file that you embed straight in your app. You can query a particular tile row,column and zoom level (the low res dataset has zoom levels 0-5) and extract the jpg data (the data format info is actually in the db so you can query that) into a byte buffer that you can pass stright into NSImage. Apart from some teething problems with the screensaver binary, this worked pretty well and I was able to get tiles rendering onscreen pretty quickly:

It's not particularly performant and I'm sure I could improve the animation by using GL or Metal directly, but I think it is good enough to warrant moving on to something new.

 Copyright (c) 2020
 Tom Horn.  All rights reserved.

 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions
 are met:
 1. Redistributions of source code must retain the above copyright
	notice, this list of conditions and the following disclaimer.
 2. Redistributions in binary form must reproduce the above copyright
	notice, this list of conditions and the following disclaimer in the
	documentation and/or other materials provided with the distribution.
 3. Redistributions in any form must be accompanied by information on
	how to obtain complete source code for the DB software and any
	accompanying software that uses the DB software.  The source code
	must either be included in the distribution or be available for no
	more than the cost of distribution plus a nominal fee, and must be
	freely redistributable under reasonable conditions.  For an
	executable file, complete source code means the source code for all
	modules it contains.  It does not include source code for modules or
	files that typically accompany the major components of the operating
	system on which the executable file runs.

 THIS SOFTWARE IS PROVIDED BY TOM HORN ``AS IS'' AND ANY EXPRESS
 OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
 NON-INFRINGEMENT, ARE DISCLAIMED.  IN NO EVENT SHALL TOM HORN
 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 THE POSSIBILITY OF SUCH DAMAGE.

Permalink - Comments - Tags: Development,Patrick O'Brian

A Patrick O'Brian Atlas

May 17, 2020, 1:22 am

After I finished my atlas of all the Patrick O'Brian novels I thought it might be cool to see all the courses I plotted on a single world map. I am working on an Apple MacOS screensaver to animate the maps, but in the meantime, here is a rendering of all the voyages.

You can click on the image for a higher resolution view.

If you are wondering about the occasional breaks in the course lines? They are a result of sections of the story where I couldn't guess where Jack and Stephen ended up. In those cases I pick up their location again once I had a fair weather observation.

Permalink - Comments - Tags: Patrick O'Brian

My Fourteen Year Project

April 11, 2020, 4:41 am

Fourteen years ago I finished reading the twenty one novels by Patrick O'Brian set during the Napoleonic wars and on various ships commanded by the protagonist Jack Aubrey and his particular friend Stephen Maturin. I decided that interactive maps of the voyages could be a useful addition to the Internet (built with the newly available Google Maps Javascript API).

Today I finished that project:

The slow, sometimes painful, progression through these twenty one volumes has ultimately been incredibly rewarding. Hundreds of thousands of people (492,902 at last count) have visited the site and many have contacted me with support and encouragement.

This site, dated, clumsy and so embarrassingly overdue for a re-write, has been a platform on which I have been able to do a lot of other fun stuff. It is something, despite its flaws, that I am very proud of.

I think it reinforces Jason Robert's assertion that "the amount of serendipity that will occur in your life, your Luck Surface Area, is directly proportional to the degree to which you do something you're passionate about".

Permalink - Comments - Tags: Patrick O'Brian,Books

Mapping of Blue at the Mizzen Complete

April 10, 2020, 11:57 pm

Blue at the Mizzen is finished.

I have developed symptoms of a cold and, as a result, quarantined myself inside our very small and already quarantined house. I am confident it is just a cold and not something more sinister but marvel at the tenacity of this particular rhinovirus that managed to circumvent the frequent handwashing, alcohol wipes and mask wearing to make it into my upper respiratory tract.

Thanks to this extra layer of enforced isolation I was able to finish this, the twentieth and last complete volume in Patrick O'Brian's wonderful series, in just 6 days. A new record, though perhaps one soon to be broken with my upcoming map of The, sadly truncated, Final Unfinished Voyage of Jack Aubrey.

Permalink - Comments - Tags: Patrick O'Brian,Books